from django.db import models

# Create your models here.

# class GitProject(models.Model):
#     projectname = models.CharField(max_length=255, verbose_name='git项目')
#     refs = models.CharField(max_length=50, verbose_name='统计分支')
#     


class GitCommit(models.Model):
    ref = models.CharField(max_length=25, verbose_name='分支')
    commitid = models.CharField(max_length=50, verbose_name='CommitID')
    shortcommitid = models.CharField(max_length=8, verbose_name='Short Commit')
    projectname = models.CharField(max_length=255, verbose_name='git项目')
    committer = models.CharField(max_length=25, verbose_name='提交人')
    committer_email = models.CharField(max_length=50, verbose_name='提交人邮箱')
    committed_date = models.DateTimeField(verbose_name='提交时间')
    merge_date = models.DateTimeField(verbose_name='合并时间', null=True, default=None)
    total = models.IntegerField(verbose_name='修改总行数')
    additions = models.IntegerField(verbose_name='新增行数')
    deletions = models.IntegerField(verbose_name='删除行数')

    class Meta:
        unique_together = ['commitid']


class GitCommitDayStat(models.Model):
    date = models.DateField(verbose_name='日期')
    ref = models.CharField(max_length=25, verbose_name='分支', default='unknown')
    committer = models.CharField(max_length=25, verbose_name='提交人')
    committed_times = models.IntegerField(verbose_name='提交次数')
    total = models.IntegerField(verbose_name='修改总行数')
    additions = models.IntegerField(verbose_name='新增行数')
    deletions = models.IntegerField(verbose_name='删除行数')

    class Meta:
        unique_together = [['date', 'committer', 'ref']]
        
        
        